home *** CD-ROM | disk | FTP | other *** search
- Path: alpha.sky.net!DMPR
- From: robertson@acm.org (Marc Robertson)
- Newsgroups: comp.lang.c++
- Subject: Re: STL
- Date: Wed, 21 Feb 96 15:19:48 GMT
- Organization: SkyNET Online
- Message-ID: <4gfdan$81f@alpha.sky.net>
- References: <4gdgt0$494@netaxs.com>
- NNTP-Posting-Host: ip104.sky.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4gdgt0$494@netaxs.com>, bobpez@netaxs.com (Bob Pesavento) wrote:
- >I'm a newbie with STL and not an expert at C++ so bear with me. Assume a
- >simplified class:
- >
- >class myclass
- >{
- > int myint;
- > float myfloat;
- >
- > public:
- >
- > (the usual... constructors etc)
- >};
- >
- >I want use "list" and stuff a bunch of these in using push_back. No
- >problem so far. But I want the user to be able to select which item to
- >sort on... myint or myfloat. What I have seen is that I can only set up
- >for one using the operator < and operator ==. I don't want multiple
- >lists. Can anyone give me an idea how to do this? Your help will be
- >appreciated.
- >
- >my e-mail addresses are:
- >bobpez@netaxs.com or Bob@chiinc.com
- >
- I'm pretty new at this also, but it looks to me that if you could
- use a deque or vector, you would be able to use the version of the
- sort algorithm that takes 2 random access iterators and a function
- object that does the compare. Then, you could pass in whatever
- function object you needed, to do the compare selected by the user.
-
- Marc Robertson
-